Class('resourcemanager', 'linb.Com',{
    Instance:{
        //base Class for this com
        base:["linb.UI"], 
        //requried class for this com
        required:["linb.UI.Dialog", "linb.UI.Pane", "linb.UI.Label", "linb.UI.Input", "linb.UI.Button", "linb.UI.TreeGrid", "linb.UI.ComboInput", "linb.UI.CheckBox", "linb.DataBinder", "linb.UI.Tabs"], 

        properties:{}, 
        rmself:null, 
        parents:null, 
        db:null, 
        events:{}, 
        iniResource:function(com, threadid){
        }, 
        iniComponents:function(){
            // [[code created by jsLinb UI Builder
            var host=this, children=[], append=function(child){children.push(child.get(0))};
            
            append((new linb.DataBinder)
                .host(host,"databinder1")
                .setName("dataset_deviceinfo")
            );
            
            append((new linb.DataBinder)
                .host(host,"databinder12")
                .setName("db_switch")
            );
            
            append((new linb.DataBinder)
                .host(host,"databinder13")
                .setName("db_host")
            );
            
            append((new linb.DataBinder)
                .host(host,"databinder4")
                .setName("db_info")
            );
            
            append((new linb.UI.Dialog)
                .host(host,"dialog1")
                .setLeft(201)
                .setTop(36)
                .setWidth(870)
                .setHeight(512)
                .setCaption("资源管理")
                .setMinBtn(false)
                .setMaxBtn(false)
                .onRender("_dialog1_onrender")
                .beforeDestroy("_dialog1_beforedestroy")
            );
            
            host.dialog1.append((new linb.UI.Pane)
                .host(host,"pane9")
                .setDock("fill")
            );
            
            host.pane9.append((new linb.UI.Button)
                .host(host,"btnSNMP")
                .setLeft(430)
                .setTop(40)
                .setCaption("收集资源信息")
                .onClick("_btnsnmp_onclick")
            );
            
            host.pane9.append((new linb.UI.Label)
                .host(host,"label2")
                .setLeft(0)
                .setTop(8)
                .setWidth(80)
                .setCaption("设备IP地址")
            );
            
            host.pane9.append((new linb.UI.Label)
                .host(host,"label3")
                .setLeft(0)
                .setTop(40)
                .setWidth(80)
                .setCaption("读共同体")
            );
            
            host.pane9.append((new linb.UI.Label)
                .host(host,"label4")
                .setLeft(240)
                .setTop(40)
                .setWidth(80)
                .setCaption("写共同体")
            );
            
            host.pane9.append((new linb.UI.Label)
                .host(host,"label5")
                .setLeft(240)
                .setTop(10)
                .setWidth(80)
                .setCaption("SNMP版本")
            );
            
            host.pane9.append((new linb.UI.Label)
                .host(host,"label6")
                .setLeft(420)
                .setTop(10)
                .setWidth(50)
                .setCaption("端口号")
            );
            
            host.pane9.append((new linb.UI.TreeGrid)
                .host(host,"resourcegrid")
                .setDirtyMark("false")
                .setDock("none")
                .setLeft(20)
                .setTop(80)
                .setWidth(560)
                .onRowSelected("_grid_onrowselected")
            );
            
            host.pane9.append((new linb.UI.Button)
                .host(host,"btnSave")
                .setLeft(250)
                .setTop(440)
                .setCaption("更新资源")
                .onClick("_btnsave_onclick")
            );
            
            host.pane9.append((new linb.UI.Button)
                .host(host,"btnDel")
                .setLeft(420)
                .setTop(440)
                .setCaption("删除资源")
                .onClick("_btndel_onclick")
            );
            
            host.pane9.append((new linb.UI.Input)
                .host(host,"ip")
                .setDataBinder("db_info")
                .setDataField("ip")
                .setLeft(90)
                .setTop(10)
                .setWidth(160)
                .setReadonly(true)
            );
            
            host.pane9.append((new linb.UI.Input)
                .host(host,"port")
                .setDataBinder("db_info")
                .setDataField("port")
                .setLeft(470)
                .setTop(10)
                .setWidth(50)
            );
            
            host.pane9.append((new linb.UI.Input)
                .host(host,"rcommunity")
                .setDataBinder("db_info")
                .setDataField("rcommunity")
                .setLeft(90)
                .setTop(40)
                .setWidth(110)
            );
            
            host.pane9.append((new linb.UI.Input)
                .host(host,"wcommunity")
                .setDataBinder("db_info")
                .setDataField("wcommunity")
                .setLeft(320)
                .setTop(40)
                .setWidth(100)
            );
            
            host.pane9.append((new linb.UI.ComboInput)
                .host(host,"version")
                .setDataBinder("db_info")
                .setDataField("version")
                .setLeft(320)
                .setTop(10)
                .setWidth(100)
                .setReadonly(true)
                .setType("listbox")
                .setItems([{"id":1, "caption":"SNMPv1", "image":"img/demo.gif"}, {"id":2, "caption":"SNMPv2", "image":"img/demo.gif"}])
                .setValue("1")
            );
            
            host.pane9.append((new linb.UI.Tabs)
                .host(host,"tabs2")
                .setItems([{"id":"h", "caption":"主机", "image":"img/demo.gif"}, {"id":"s", "caption":"网络设备", "image":"img/demo.gif"}])
                .setDock("none")
                .setLeft(20)
                .setTop(260)
                .setWidth(560)
                .setHeight(160)
                .setTabindex(null)
                .setVisibility("hidden")
                .setValue("h")
            );
            
            host.tabs2.append((new linb.UI.Label)
                .host(host,"label13")
                .setLeft(10)
                .setTop(20)
                .setWidth(70)
                .setCaption("资源编号")
            , 's');
            
            host.tabs2.append((new linb.UI.Label)
                .host(host,"label14")
                .setLeft(290)
                .setTop(20)
                .setWidth(50)
                .setCaption("类型")
            , 's');
            
            host.tabs2.append((new linb.UI.Label)
                .host(host,"label15")
                .setLeft(310)
                .setTop(50)
                .setWidth(30)
                .setCaption("速率")
            , 's');
            
            host.tabs2.append((new linb.UI.Label)
                .host(host,"label31")
                .setLeft(30)
                .setTop(50)
                .setWidth(50)
                .setCaption("描述")
            , 's');
            
            host.tabs2.append((new linb.UI.Label)
                .host(host,"label32")
                .setLeft(20)
                .setTop(80)
                .setWidth(60)
                .setHeight(12)
                .setCaption("配置状态")
            , 's');
            
            host.tabs2.append((new linb.UI.Label)
                .host(host,"label33")
                .setLeft(280)
                .setTop(80)
                .setWidth(60)
                .setCaption("工作状态")
            , 's');
            
            host.tabs2.append((new linb.UI.Input)
                .host(host,"interfaceindex")
                .setDataBinder("db_switch")
                .setDataField("ifIndex")
                .setLeft(90)
                .setTop(20)
            , 's');
            
            host.tabs2.append((new linb.UI.Input)
                .host(host,"interfacedescri")
                .setDataBinder("db_switch")
                .setDataField("ifDescri")
                .setLeft(90)
                .setTop(50)
                .setWidth(190)
            , 's');
            
            host.tabs2.append((new linb.UI.ComboInput)
                .host(host,"interfacetype")
                .setDataBinder("db_switch")
                .setDataField("ifType")
                .setLeft(350)
                .setTop(20)
                .setWidth(170)
                .setItems([{"id":"a", "caption":"item a", "image":"img/demo.gif"}, {"id":"b", "caption":"item b", "image":"img/demo.gif"}, {"id":"c", "caption":"item c", "image":"img/demo.gif"}, {"id":"d", "caption":"item d", "image":"img/demo.gif"}])
                .setValue("a")
            , 's');
            
            host.tabs2.append((new linb.UI.Input)
                .host(host,"interfacespeed")
                .setDataBinder("db_switch")
                .setDataField("ifSpeed")
                .setLeft(350)
                .setTop(50)
                .setWidth(110)
            , 's');
            
            host.tabs2.append((new linb.UI.ComboInput)
                .host(host,"interfaceadmin")
                .setDataBinder("db_switch")
                .setDataField("ifAdminStatus")
                .setLeft(90)
                .setTop(80)
                .setValue("a")
            , 's');
            
            host.tabs2.append((new linb.UI.ComboInput)
                .host(host,"interfaceoper")
                .setDataBinder("db_switch")
                .setDataField("ifOperStatus")
                .setLeft(350)
                .setTop(80)
                .setValue("a")
            , 's');
            
            host.tabs2.append((new linb.UI.Input)
                .host(host,"switch_interface_id")
                .setDataBinder("db_switch")
                .setDataField("id")
                .setLeft(30)
                .setTop(100)
                .setVisibility("hidden")
            , 's');
            
            host.tabs2.append((new linb.UI.Input)
                .host(host,"switch_id")
                .setDataBinder("db_switch")
                .setDataField("hostid")
                .setLeft(240)
                .setTop(110)
                .setVisibility("hidden")
            , 's');
            
            host.tabs2.append((new linb.UI.Input)
                .host(host,"switch_ip")
                .setDataBinder("db_switch")
                .setDataField("host")
                .setLeft(380)
                .setTop(110)
                .setVisibility("hidden")
            , 's');
            
            host.tabs2.append((new linb.UI.Label)
                .host(host,"label7")
                .setLeft(-10)
                .setTop(20)
                .setWidth(80)
                .setCaption("资源编号")
            , 'h');
            
            host.tabs2.append((new linb.UI.Label)
                .host(host,"label8")
                .setLeft(210)
                .setTop(20)
                .setWidth(60)
                .setCaption("描述")
            , 'h');
            
            host.tabs2.append((new linb.UI.Label)
                .host(host,"label9")
                .setLeft(20)
                .setTop(70)
                .setWidth(50)
                .setCaption("类型")
            , 'h');
            
            host.tabs2.append((new linb.UI.Label)
                .host(host,"label10")
                .setLeft(230)
                .setTop(70)
                .setWidth(40)
                .setCaption("容量")
            , 'h');
            
            host.tabs2.append((new linb.UI.Input)
                .host(host,"hostindex")
                .setDataBinder("db_host")
                .setDataField("hrindex")
                .setLeft(80)
                .setTop(20)
            , 'h');
            
            host.tabs2.append((new linb.UI.ComboInput)
                .host(host,"hosttype")
                .setDataBinder("db_host")
                .setDataField("hrType")
                .setLeft(80)
                .setTop(70)
                .setItems([{"id":"a", "caption":"item a", "image":"img/demo.gif"}, {"id":"b", "caption":"item b", "image":"img/demo.gif"}, {"id":"c", "caption":"item c", "image":"img/demo.gif"}, {"id":"d", "caption":"item d", "image":"img/demo.gif"}])
                .setValue("a")
            , 'h');
            
            host.tabs2.append((new linb.UI.Input)
                .host(host,"hostdescri")
                .setDataBinder("db_host")
                .setDataField("hrDescri")
                .setLeft(280)
                .setTop(20)
                .setWidth(240)
            , 'h');
            
            host.tabs2.append((new linb.UI.Input)
                .host(host,"host_resource_id")
                .setDataBinder("db_host")
                .setDataField("id")
                .setLeft(20)
                .setTop(100)
                .setVisibility("hidden")
            , 'h');
            
            host.tabs2.append((new linb.UI.Input)
                .host(host,"host_id")
                .setDataBinder("db_host")
                .setDataField("hostid")
                .setLeft(160)
                .setTop(100)
                .setVisibility("hidden")
            , 'h');
            
            host.tabs2.append((new linb.UI.Input)
                .host(host,"host_ip")
                .setDataBinder("db_host")
                .setDataField("host")
                .setLeft(300)
                .setTop(100)
                .setVisibility("hidden")
            , 'h');
            
            host.tabs2.append((new linb.UI.Input)
                .host(host,"hostsize")
                .setDataBinder("db_host")
                .setDataField("hrSize")
                .setLeft(280)
                .setTop(70)
                .setValue("0")
            , 'h');
            
            host.pane9.append((new linb.UI.Button)
                .host(host,"button10")
                .setLeft(70)
                .setTop(440)
                .setCaption("保存所有资源")
                .onClick("_button10_onclick")
            );
            
            host.dialog1.append((new linb.UI.Pane)
                .host(host,"pane6")
                .setDock("left")
                .setWidth(270)
            );
            
            host.pane6.append((new linb.UI.Label)
                .host(host,"label1")
                .setLeft(0)
                .setTop(20)
                .setWidth(70)
                .setCaption("设备IP地址")
            );
            
            host.pane6.append((new linb.UI.Input)
                .host(host,"ip_search")
                .setLeft(70)
                .setTop(20)
                .setWidth(150)
            );
            
            host.pane6.append((new linb.UI.Button)
                .host(host,"btnSearch")
                .setLeft(158)
                .setTop(48)
                .setWidth(62)
                .setCaption("查询")
                .onClick("_btnsearch_onclick")
            );
            
            host.pane6.append((new linb.UI.TreeGrid)
                .host(host,"devicegrid")
                .setDock("none")
                .setTop(80)
                .setWidth(270)
                .setHeight(380)
                .setHeader([{"id":"id", "width":20, "type":"label", "caption":"ID"}, {"id":"ip", "width":100, "type":"label", "caption":"设备IP"}, {"id":"dtype", "width":10, "type":"label", "caption":"dtype"}, {"id":"descri", "width":80, "type":"label", "caption":"设备类型"}])
                .onRowSelected("_devicegrid_onrowselected")
                .beforeRowActive("_devicegrid_beforerowactive")
            );
            
            return children;
            // ]]code created by jsLinb UI Builder
        }, 
        iniExComs:function(com, hreadid){
        }, 
        setWhoisParent:function(myparents) {
            parents = myparents;
        }, 
        CallRemote:function(cmd,datas,processfun,method){
            var option=null;
            if (method == null || method=="") {
                option = "{'method':'"+"get"+"'}";
            } else {
                option = method;
            }
            
            linb.request("/NetDM4Web/resourcemanager.do","cmd="+cmd+"&datas="+datas,
            function(rep, type){
                returnpkg = _.unserialize(rep);
                processfun(returnpkg);
            },
            function() {
                linb.UI.Dialog.alert('提示','网络连接出现问题，无法获得数据，请稍候重试');
            },0,_.unserialize(option));
        }, 

        resetRow:function(tg,row,newvalueobject){
            var headerlist = tg.getHeader();
            for (var j =0;j < headerlist.length;j++) {
                if ((headerlist[j].id in newvalueobject) && typeof(newvalueobject[headerlist[j].id]) != "function") {
                    tg.updateCellByRowCol(row.id,headerlist[j].id,newvalueobject[headerlist[j].id],false);
                }
            }
            rmself.setSelector(tg,row);
        }, 
        getJsonGridDatas:function(commitrow) {
            var currow = commitrow;
            var hs =rmself.resourcegrid.getHeader();
            var jsons="";
            var jsondata = "";
            for (var i =0;i < hs.length;i++) {
                if (_.isNumb(currow.cells[i].value)) {
                    jsons = jsons+"'"+hs[i].id+"':"+currow.cells[i].value+"";
                   } else {
                    jsons = jsons+"'"+hs[i].id+"':'"+currow.cells[i].value+"'";
                }
                if (i < hs.length-1) {
                    jsons = jsons+",";
                }
            }
            jsondata = jsondata + "{"+jsons+"}";
            return jsondata;
        }, 
        process_saveok:function(pkg) {
        	if (pkg.code < 0) {
	            alert(pkg.messages);    
	        }
        }, 
        process_rowselected:function(profile,row,src) {
            rmself.btnSave.setTag(0);
            var hs = rmself.resourcegrid.getHeader();
            var dbv="";
            for (var i=0;i < hs.length;i++) {
                dbv = dbv + "'"+hs[i].id+"':'"+row.cells[i].value+"'"
                if (i != hs.length-1) {
                   dbv =  dbv + ","
                }
            }
            dbv = "{"+dbv+"}";
            if (rmself.$row.cells[2].value == 0) {
                rmself.tabs2.setValue("h");
                rmself.databinder13.resetValue(_.unserialize(dbv));
            } else {
                rmself.tabs2.setValue("s");
                rmself.databinder12.resetValue(_.unserialize(dbv));
            }
            rmself.$resrow = row;            
        }, 
        commitds:function(profile,row,src,ds) {
            //alert(ds);
            rmself.CallRemote('save',ds,rmself.process_saveok,"{method:'get',asy:false}");
            rmself.btnSave.setTag(0);                    
            rmself.process_rowselected(profile,row,src);
        }, 
        process_commitds:function(profile,row,src,devicerow,commitrow) {
            if (devicerow != null) {                        
                var ccell = devicerow.cells;
                var jcell = "'"+"device"+"':"+"{'"+"id"+"':"+ccell[0].value+",'"+"ip"+"':"+ccell[1].value+",'"+"dtype"+"':"+ccell[2].value+"}";
                var ds = "{"+jcell +",'"+ "rows"+"' : "+rmself.getJsonGridDatas(commitrow)+"}";
                rmself.commitds(profile,row,src,ds);
            } // end of if

        }, 
        _grid_onrowselected:function (profile, row, src) {
            if (rmself.$resrow == null) {
                rmself.$resrow = row;
                rmself.process_rowselected(profile,row,src);
            } else {
                var beforerow = rmself.$resrow;
                if (rmself.$row.cells[2].value == 0) {
                    if (rmself.hostindex.isDirtied() || rmself.hostdescri.isDirtied() || rmself.hosttype.isDirtied() || rmself.hostsize.isDirtied()) {
                        rmself.btnSave.setTag(1);
                        if (rmself.btnSave.getTag() == 1) { //has changed!                            
                            linb.UI.Dialog.confirm('警告',
                            '当前记录已经被修改，是否保存修改的数据？点击[是的]进行修改，点击[不是]放弃改变。',
                            function(){
                                rmself.resetRow(rmself.resourcegrid,beforerow,rmself.databinder13.getValue());                            
                                rmself.process_commitds(profile,row,src,rmself.$row,beforerow);
                            },
                            function(){
                                rmself.process_rowselected(profile,row,src);
                            });
                        }
                    } else {
                        rmself.process_rowselected(profile,row,src);
                    }
                }
                if (rmself.$row.cells[2].value == 1) {
                    if (rmself.interfaceindex.isDirtied() || rmself.interfacedescri.isDirtied() || rmself.interfacetype.isDirtied() || rmself.interfacespeed.isDirtied() || rmself.interfaceadmin.isDirtied() || rmself.interfaceoper.isDirtied()) {
                        rmself.btnSave.setTag(1);
                        if (rmself.btnSave.getTag() == 1) { //has changed!
                            linb.UI.Dialog.confirm('警告',
                            '当前记录已经被修改，是否保存修改的数据？点击[是的]进行修改，点击[不是]放弃改变。',
                            function(){
                                rmself.resetRow(rmself.resourcegrid,beforerow,rmself.databinder12.getValue());                            
                                rmself.process_commitds(profile,row,src,rmself.$row,beforerow);
                            },
                            function(){
                                rmself.process_rowselected(profile,row,src);
                            });
                        }
                    }else {
                        rmself.process_rowselected(profile,row,src);
                    }
                }
             }

        }, 
        _dialog1_beforedestroy:function (profile) {
            if (parents != null) {
                oo = _.unserialize(parents.menubar1.getTagVar());
                oo.mmodify_resource = 0;
                parents.menubar1.setTagVar(_.serialize(oo));
            }
            linb.DataBinder.destroyAll();
            return true;
        }, 
        SNMPObject:function() {
            this.ip = '127.0.0.1';
            this.dtype = 1;
            this.version = 1;
            this.port = 161;
            this.rcommunity = 'public';
            this.wcommunity = 'public';
        }, 
        initGrid:function(h) {
            rmself.resourcegrid.setHeader(h.struct);
            var hs = h.hidelist.split(',');
            for (var x=0;x < hs.length;x++) {
                rmself.resourcegrid.showColumn(hs[x],false);
            }
        }, 
        getColIndex:function(sender,col) {
            var hs = sender.getHeader();
            for (var m=0;m<hs.length;m++) {
                if (hs[m].id==col) {
                    return m;
                }
            }
            return -1;
        }, 
        c2v:function(items,c) {
            for (var j=0;j<items.length;j++) {

                if ( c == items[j].caption) {
                    return items[j].id;
                }
            }
        }, 
        v2c:function(items,v) {
            for (var j=0;j<items.length;j++) {

                if ( v == items[j].id) {
                    return items[j].caption;
                }
            }
        }, 
        v2cByCol:function(sender,col,items){
            var rows = sender.getRows();
            for (var i=0;i < rows.length;i++) {
                rmself.v2cByRowCol(sender,rows[i].id,col,items);
            }
        }, 
        v2cByRowCol:function(sender,x,y,items){
            var v = rmself.resourcegrid.getCellbyRowCol(x,y).value;
            var colindex = rmself.getColIndex(sender,y);
            var c = rmself.v2c(items,v);
            var s = "{"+"'"+"value"+"'"+":'"+v+"',"+"'"+"caption"+"'"+":'"+c+"'}";

            var o = _.unserialize(s);
            sender.updateCellByRowCol(x,y,o,false);
        }, 
        process_search:function(pkg) {
            if (pkg.code == 0) {
                rmself.devicegrid.setRows(_.unserialize(pkg.datas));
            } else {
                linb.UI.Dialog.alert('提示',pkg.messages);
            }
        }, 
        _dialog1_onrender:function(profile) {
            rmself = this;
            rmself.btnSave.setTag(0);
            rmself.CallRemote('init','tmp',function(pkg){
                if (pkg.code== 0) {
                    var sels = _.unserialize(pkg.datas);
                    rmself.hosttype.setItems(sels.hrtype);
                    rmself.interfacetype.setItems(sels.iftype);
                    rmself.interfaceadmin.setItems(sels.ifadminstatus);
                    rmself.interfaceoper.setItems(sels.ifoperstatus);
                    rmself.$hrtype = sels.hrtype;
                    rmself.$iftype = sels.iftype;
                    rmself.$ifadminstatus = sels.ifadminstatus;
                    rmself.$ifoperstatus = sels.ifoperstatus;
                } else {
                    linb.UI.Dialog.alert('提示','网络连接出现问题，无法获得数据，请稍候重试');
                }
            });
            rmself.devicegrid.showColumn('dtype',false);
            rmself.$row = null;
            rmself.CallRemote('list','',rmself.process_search);
        }, 
        setSelector:function(sender,currow) {
            var col = rmself.$gridselector.split(',');
            for (var z=0;z<col.length;z++) {
               if (col[z]=='hrType') {
                    rmself.v2cByRowCol(sender,currow.id,col[z],rmself.hosttype.getItems());
               }
               if (col[z]=='ifType') {
                    rmself.v2cByRowCol(sender,currow.id,col[z],rmself.interfacetype.getItems());
               }
               if (col[z]=='ifAdminStatus') {
                    rmself.v2cByRowCol(sender,currow.id,col[z],rmself.interfaceadmin.getItems());
               }
               if (col[z]=='ifOperStatus') {
                    rmself.v2cByRowCol(sender,currow.id,col[z],rmself.interfaceoper.getItems());
               }
            }


        }, 

        setAllSelector:function(cols) {
            var col = cols.split(',');
            for (var y=0;y<col.length;y++) {
               if (col[y]=='hrType') {
                    rmself.v2cByCol(rmself.resourcegrid,col[y],rmself.hosttype.getItems());
               }
               if (col[y]=='ifType') {
                    rmself.v2cByCol(rmself.resourcegrid,col[y],rmself.interfacetype.getItems());
               }
               if (col[y]=='ifAdminStatus') {
                    rmself.v2cByCol(rmself.resourcegrid,col[y],rmself.interfaceadmin.getItems());
               }
               if (col[y]=='ifOperStatus') {
                    rmself.v2cByCol(rmself.resourcegrid,col[y],rmself.interfaceoper.getItems());
               }

            }
        }, 

        process_displayinfo:function(pkg) {
            if (pkg.code == 0) {
                rmself.resourcegrid.removeAllRows();
                var so = _.unserialize(pkg.datas);
                rmself.databinder4.resetValue(so.info);
                var headerinfo = _.unserialize(so.header);
                rmself.initGrid(headerinfo);
                rmself.resourcegrid.setRows(_.unserialize(so.rows));
                rmself.$gridselector = headerinfo.selectorlist;
                rmself.setAllSelector((rmself.$gridselector));
            }
            if (pkg.code < 0){
                linb.UI.Dialog.alert('提示',pkg.messages);
            }
        }, 
        _devicegrid_onrowselected:function(profile,row,src) {
            rmself.$row = row;
            var selso = new rmself.SNMPObject();
            selso.id = row.cells[0].value;
            selso.ip = row.cells[1].value;
            selso.dtype = row.cells[2].value;
            if (selso.dtype == 0) {
                rmself.tabs2.setValue("h");
            }
            if (selso.dtype == 1) {
                rmself.tabs2.setValue("s");
            }
            rmself.btnSNMP.setTag(selso.dtype);
            rmself.$resrow = null;
            rmself.CallRemote('listr',_.serialize(selso),rmself.process_displayinfo);

        }, 
        _btnsearch_onclick:function (profile, e, src, value) {
            rmself.CallRemote('search',rmself.ip_search.updateValue().getValue(),rmself.process_search);
        }, 
        hasChanged:function() {
            if (rmself.resourcegrid.getRows().length > 0 && rmself.btnSave.getTag() == 1) {
                return true;
            }
            return false;
        }, 
        _btnsave_onclick:function (profile, e, src, value) {
            if ((rmself.resourcegrid.getRows().length != 0) && (rmself.$row != null) && (rmself.$resrow != null)) {
                if (rmself.$row.cells[2].value == 0) {
                    if (rmself.hostindex.isDirtied() || rmself.hostdescri.isDirtied() || rmself.hosttype.isDirtied() || rmself.hostsize.isDirtied()) {
                        rmself.btnSave.setTag(1);
                        rmself.resetRow(rmself.resourcegrid,rmself.$resrow,rmself.databinder13.getValue());
                        rmself.process_commitds(profile,rmself.$resrow,src,rmself.$row,rmself.$resrow);
                    } else {
                        linb.UI.Dialog.alert('提示','没有数据需要被提交。');
                    }
                }
                if (rmself.$row.cells[2].value == 1) {
                    //alert((rmself.interfaceindex.isDirtied() || rmself.interfacedescri.isDirtied() || rmself.interfacetype.isDirtied() || rmself.interfacespeed.isDirtied() || rmself.interfaceadmin.isDirtied() || rmself.interfaceoper.isDirtied()));
                    if (rmself.interfaceindex.isDirtied() || rmself.interfacedescri.isDirtied() || rmself.interfacetype.isDirtied() || rmself.interfacespeed.isDirtied() || rmself.interfaceadmin.isDirtied() || rmself.interfaceoper.isDirtied()) {
                        rmself.btnSave.setTag(1);
                        rmself.resetRow(rmself.resourcegrid,rmself.$resrow,rmself.databinder12.getValue());
                        rmself.process_commitds(profile,rmself.$resrow,src,rmself.$row,rmself.$resrow);
                    }else {
                        linb.UI.Dialog.alert('提示','没有数据需要被提交。');
                    }
                }

            } else {
                linb.UI.Dialog.alert('提示','没有数据需要被提交。');
            }
        }, 
        process_snmp:function(pkg) {
            rmself.process_displayinfo(pkg);
        }, 
        _btnsnmp_onclick:function (profile, e, src, value) {
            var upso = new rmself.SNMPObject();
            upso.ip = rmself.ip.updateValue().getValue();
            upso.dtype = rmself.btnSNMP.getTag();
            upso.ver = rmself.version.updateValue().getValue();
            upso.port = rmself.port.updateValue().getValue();
            upso.rcommunity = rmself.rcommunity.updateValue().getValue();
            upso.wcommunity = rmself.wcommunity.updateValue().getValue();
            rmself.CallRemote('fr',_.serialize(upso),rmself.process_snmp);
        }, 
        process_del:function(pkg) {
            if (pkg.code == 0) {
                linb.UI.Dialog.alert('提示',pkg.messages);
                rmself.resourcegrid.removeRows(rmself.$resrow.id);
                rmself.$resrow = null;
            } else {
                linb.UI.Dialog.alert('提示',pkg.messages);
            }
        }, 
        _btndel_onclick:function (profile, e, src, value) {
        	if (rmself.$row != null && rmself.$resrow != null) {
               linb.UI.Dialog.confirm('警告',
               '是否删除当前记录？点击[是的]执行操作，点击[不是]放弃操作。',
               function(){
	             var reshostid = -1;
	             var resindex = -1;
	             var colpos = rmself.getColIndex(rmself.resourcegrid,'hostid');
	             if (colpos > -1) {
	             	reshostid = rmself.$resrow.cells[colpos].value;
	             }
	             if (rmself.$row.cells[2].value == 0) {
		             colpos = rmself.getColIndex(rmself.resourcegrid,'hrindex');
		             if (colpos > -1) {
	    	         	resindex = rmself.$resrow.cells[colpos].value;
	        	     }
	        	 }
	             if (rmself.$row.cells[2].value == 1) {
		             colpos = rmself.getColIndex(rmself.resourcegrid,'ifIndex');
		             if (colpos > -1) {
	    	         	resindex = rmself.$resrow.cells[colpos].value;
	        	     }
	        	 }
	        	 var ds = "{'"+"hostid"+"':"+reshostid+",'"+"index"+"':"+resindex+"}";
	             rmself.CallRemote('delete',ds,rmself.process_del,"{'method':'get',asy:false}");
               },
               function(){
                   
               });
			}			
        }, 
        _devicegrid_beforerowactive:function (profile, row) {
        }, 
        process_commitallres:function(pkg) {
        	if (pkg.code <0) {
        		rmself.$founderror = true;
        	} else {
        		rmself.$founderror = false;
        	}
        },
        _button10_onclick:function (profile, e, src, value) {
        	var resrows = rmself.resourcegrid.getRows();        	
        	var currow = null;
            var ccell = rmself.$row.cells;
            var jcell = "'"+"device"+"':"+"{'"+"id"+"':"+ccell[0].value+",'"+"ip"+"':"+ccell[1].value+",'"+"dtype"+"':"+ccell[2].value+"}";        	        	
        	for (var i = 0;i < resrows.length;i++) {
        		currow = resrows[i];        		
        		var colpos = rmself.getColIndex(rmself.resourcegrid,'hostid');
        		if (colpos > -1) {
        			if (currow.cells[colpos].value == -1) {
        				rmself.resourcegrid.updateCellByRowCol(currow.id,'hostid',ccell[0].value,false)
        			}
        		}
        		var colpos = rmself.getColIndex(rmself.resourcegrid,'host');
        		if (colpos > -1) {
        			if (currow.cells[colpos].value == -1) {
        				rmself.resourcegrid.updateCellByRowCol(currow.id,'host',ccell[1].value,false)
        			}
        		}
        		
        		currow = resrows[i];
                var ds = "{"+jcell +",'"+ "rows"+"' : "+rmself.getJsonGridDatas(currow)+"}";            
	            rmself.CallRemote('save',ds,rmself.process_commitallres,"{method:'get',asy:false}");
	            if (rmself.$founderror == null || rmself.$founderror == true) {
	            	linb.UI.Dialog.alert('提示','提交资源信息时发生了错误，已经成功提交的数据不会被回退。');
	            	break;
	            }
			}
			if (rmself.$founderror != null && rmself.$founderror == false) {
				linb.UI.Dialog.alert('提示','已经成功保存了资源信息。');
			}
        }
    }
}
);